#include<iostream>
#include<queue>
using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
int dx[] = { 0,-1,0,1 };
int dy[] = { -1,0,1,0 };
int g[10][10];
queue<PII>q;
PII pre[10][10];
int st[10][10];
int dis[10][10];
void bfs(int sx, int sy)
{
	q.push(make_pair(sx, sy));
	st[sx][sy] = 1;
	while (q.size()) {
		PII t = q.front();
		q.pop();
		for (int i = 0; i < 4; i++) {
			int a = dx[i] + t.x;
			int b = dy[i] + t.y;
			if (st[a][b])continue;
			if (a < 0 || a >= 5 || b < 0 || b >= 5)continue;
			if (g[a][b]) continue;
			st[a][b] = 1;
			q.push(make_pair(a, b));
			dis[a][b] = dis[t.x][t.y] + 1;
			pre[a][b] = make_pair(t.x, t.y);
			if (a == 0 && b == 0) {
				return;
			}
		}
	}
}
int main()
{
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			cin >> g[i][j];
		}
	}
	bfs(4, 4);
	//cout << dis[0][0] << endl;
	int x1 = 0, y1 = 0;
	cout << "(0, 0)" << endl;
	int a, b;
	while (x1 != 4 && y1 != 4) {
		cout << "(" << pre[x1][y1].x << ", " << pre[x1][y1].y << ")" << endl;
		a = pre[x1][y1].x;
		b = pre[x1][y1].y;
		x1 = a;
		y1 = b;
	}
	cout << "(" << pre[x1][y1].x << ", " << pre[x1][y1].y << ")" << endl;
	cout << "(4, 4)" << endl;
	/*cout << pre[2][0].x<<"       "<<pre[2][0].y << endl;
	cout << pre[2][4].x << "       " << pre[2][4].y << endl;*/
	return 0;
}